<%-- 
    Document   : CustomerRegistration
    Created on : 2012-maj-06, 15:29:58
    Author     : scartissue
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%--
<jsp:useBean id="user" class="com.webbucks.userBean" scope="session"/>
<jsp:setProperty name="user" property="*"/>
--%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>WebBucks Online Coffee Company!</title>
        <script type="text/javascript">
            function validateForm(){
                var rValue = true;
                var alertString = "";
                var x=document.forms["registerForm"]["uname"].value;
                if (x==null || x==""){
                    alertString = alertString + "UserName name must be filled out \n";
                    //CHECK IF USERNAME IS ALREADY IN THE DB
                    rValue = false;
                }
                x=document.forms["registerForm"]["mail"].value;
                var atpos=x.indexOf("@");
                var dotpos=x.lastIndexOf(".");
                if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length){
                    alertString = alertString + "Not a valid e-mail address \n";
                    rValue = false;
                }
                x=document.forms["registerForm"]["fName"].value;
                if (x==null || x==""){
                    alertString = alertString + "First name must be filled out \n";
                    rValue = false;
                }
                x=document.forms["registerForm"]["lName"].value;
                if (x==null || x==""){
                    alertString = alertString + "Last name must be filled out \n";
                    rValue = false;
                }
                x=document.forms["registerForm"]["persNumber"].value;
                if (x==null || x==""){
                    alertString = alertString + "Personal Number must be filled out \n";
                    rValue = false;
                }
                var x=document.forms["registerForm"]["str"].value;
                if (x==null || x==""){
                    alertString = alertString + "Street must be filled out \n";
                    rValue = false;
                }
                x=document.forms["registerForm"]["strNumber"].value;
                if (x==null || x==""){
                    alertString = alertString + "Street Number must be filled out \n";
                    rValue = false;
                }
                if(is_int(x) == false ){
                   alertString = alertString + "Street Number must be a realnumber \n";
                   rValue = false; 
                }
                
                var x=document.forms["registerForm"]["cit"].value;
                if (x==null || x==""){
                    alertString = alertString + "City must be filled out \n";
                    rValue = false;
                }
                x=document.forms["registerForm"]["postNumber"].value;
                if (x==null || x==""){
                    alertString = alertString + "Postal Number must be filled out \n";
                    rValue = false;
                }
                if(is_int(x) == false ){
                   alertString = alertString + "Postal Number must be a realnumber \n";
                   rValue = false; 
                }
                
                if(alertString != ""){
                    alert(alertString);
                }        
                return rValue;     
            }
            
            
            function is_int(value){ 
                if((parseFloat(value) == parseInt(value)) && !isNaN(value)){
                    return true;
                }
                else { 
                    return false;
                } 
            }
        </script>
        
        
    </head>
    <body>
        <form method="POST" action="SIDAN SOM TAR HAND OM LOGIN">
            <div align="center">
                Username: <input type="text" name="username" size="15" /><br />
                Password: <input type="password" name="passwort" size="15" /><br />
                <p><input type="submit" value="Login" /></p>
                
                
                
                
            </div>
        </form>
        
        <form name="registerForm" onsubmit="return validateForm();" method="POST" action="http://localhost:8080/webbucks-war/Register">
            <div align="center">
                Username: <input type="text" name="uname" size="15" value="johannes"/><br />
                Email: <input type="text" name="mail" size="15" value="johannes@nilsson.com"/><br />
                First Name: <input type="text" name="fName" size="15" value="Johannes"/><br /> 
                Last Name: <input type="text" name="lName" size="15" value="Nilsson"/><br />
                Personal Number: <input type="text" name="persNumber" size="15" value="123"/><br />
                Street: <input type="text" name="str" size="15" value="djakne"/><br />
                Street Number: <input type="text" name="strNumber" size="15" value="123"/><br />
                city: <input type="text" name="cit" size="15" value="uppsala"/><br />
                postalNumber: <input type="text" name="postNumber" size="15" value="123"/><br />
                Password: <input type="password" name="pass" size="15" value="asdf"/><br />
                confirm Password: <input type="password" name="confirmPassword" size="15" value="asdf"/><br />
                
                <p><input type="submit" value="Registrera" /></p>
            </div>
        </form>
        <%-- 
        <div align="center">    
            UserName: <jsp:getProperty name="user" property="username" /><br> 
            Password: <jsp:getProperty name="user" property="password" /><br>
            Conf Pass: <jsp:getProperty name="user" property="confirmPassword" /><br> 
            Email: <jsp:getProperty name="user" property="email" /><br> 
            First name: <jsp:getProperty name="user" property="firstName" /><br> 
            Last Name: <jsp:getProperty name="user" property="lastName" /><br> 
            Personal Number: <jsp:getProperty name="user" property="personalNumber" /><br> 
            Street: <jsp:getProperty name="user" property="street" /><br> 
            Street Number: <jsp:getProperty name="user" property="streetNumber" /><br> 
            City: <jsp:getProperty name="user" property="city" /><br> 
            Postal Number: <jsp:getProperty name="user" property="postalNumber" /><br> 
        </div>  
        --%>
    </body>
</html>
